package jnpf.engine.custom.cmd.commons;

import jnpf.engine.util.SpringContextHolder;
import org.flowable.common.engine.impl.interceptor.Command;
import org.flowable.common.engine.impl.interceptor.CommandContext;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityManager;
import org.flowable.spring.SpringProcessEngineConfiguration;

public class RemoveProcCmd implements Command<ExecutionEntityManager> {
    private String processInstanceId;
    @Override
    public ExecutionEntityManager execute(CommandContext commandContext) {
        SpringProcessEngineConfiguration springProcessEngineConfiguration = SpringContextHolder.getBean(SpringProcessEngineConfiguration.class);
        springProcessEngineConfiguration.getHistoricProcessInstanceEntityManager().delete(processInstanceId);
        return null;
    }

    public RemoveProcCmd(String processInstanceId) {
        this.processInstanceId = processInstanceId;
    }
}
